<template>
  <div id="points_id">
    <!-- 上层注释以及添加按钮 -->
    <div class="points_id_top">
      <div class="points_id_left">
        注：<br />
        1.增加的新栏目为当前栏目的下一行<br />
        2.修改完的栏目一行需要后提交审批才能生效
      </div>
      <div class="points_id_right">
        <el-button round @click="add">增加</el-button>
      </div>
    </div>
    <!-- 下层渲表格 -->
    <el-table
      :data="points_list"
      style="width: 100%; margin-bottom: 20px; margin-top: 20px"
      row-key="id"
      border
      :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
    >
      <el-table-column prop="id" label="编号"> </el-table-column>
      <el-table-column prop="catename" label="类别名称"> </el-table-column>
      <el-table-column prop="img" label="类别图片" v-slot="$img">
        <template>
          <img
            :src="lujing + $img.row.img"
            alt=""
            v-if="$img.row.img != ''"
            class="img_size"
          />
        </template>
      </el-table-column>
      <el-table-column label="状态" prop="status" v-slot="$s" width="155">
        <template>
          <el-button round size="mini" type="success" v-if="$s.row.status == 1">
            已启用
          </el-button>
        </template>
        <template>
          <el-button round size="mini" type="danger" v-if="$s.row.status == 0">
            已禁用
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作" v-slot='shuju'>
        <template>
          <el-button round class="xiugai" type="warning" size="mini"
            @click="xiugai(shuju.row)">修改</el-button
          >
        </template>
        <template>
          <el-button round class="shanchu" type="danger" size="mini" @click="shanchu(shuju.row.id)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <addpoints :isShow="isShow" @addpointss="addpointss" ref="add_pointss"></addpoints>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
import addpoints from "../components/addpoints.vue";
export default {
  data() {
    return {
      isShow: { sta: false },
    };
  },
  created() {
    this.PointsActions();
  },
  methods: {
    shanchu(id){
     this.$http.post('/api/catedelete',{id}).then(res=>{
       if(res.code==200){
         alert('删除成功')
       }
     })
     this.PointsActions();
    },
    xiugai(obj){
      this.isShow.sta=true
      this.$refs.add_pointss.xiugaiadd(obj)
    },
    addpointss() {
      this.PointsActions();
    },
    add() {
      this.isShow.sta = true;
    },
    ...mapActions("PointsStore", ["PointsActions"]),
  },
  computed: {
    ...mapState({ points_list: (state) => state.PointsStore.points_list }),
  },
  components: {
    addpoints,
  },
};
</script>

<style>
#points_id .points_id_top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#points_id .points_id_top .points_id_left {
  font-size: 12px;
  color: #c4c4c4;
}
#points_id .points_id_top .points_id_right button {
  height: 10px;
  line-height: 2px;
  font-size: 12px;
  color: #ffa998;
}
#points_id .img_size {
  width: 100%;
  height: 100%;
  /* background-size:100% 100% ; */
}
</style>